package rs.util;

/* Classe necessaria a convertire alcuni caratteri speciali contenuti nelle stringhe.
 * Esempio:
 * 		"Guns N' Roses"					->		"Guns+N%27+Roses"
 * 		"Florence + the Machine"		->		"Florence+%2B+the Machine" * 
 * */
public class CanonicalString {
	
	private String word;
	
	public CanonicalString(String s) {
		this.word = "";
		for (char c : s.toCharArray()) {
			switch (c) {
				case '#' : this.word += "%23"; break;
				case '&' : this.word += "%26"; break;
				case '\'' : this.word += "%27"; break;
				case '+' : this.word += "%2B"; break;
				case '/' : this.word += "%2F"; break;
				case ' ' : this.word += "+"; break;
				default: this.word += c;
			}
		}
	}
	
	public String toString() {
		return this.word;
	}

}
